package com.ztman.router.common.base;

import android.os.Bundle;
import android.support.annotation.Nullable;

import butterknife.ButterKnife;
import butterknife.Unbinder;
import me.yokeyword.fragmentation.SupportActivity;

/**
 * @Title:AbstractGrandFatherActivity
 * @Package:com.ztman.router.common.base
 * @Description:
 * @Auther:YJH
 * @Email:yuannunhua@gmail.com
 * @Date:2018/5/149:15
 */
public abstract class AbstractGrandFatherActivity extends SupportActivity {

    private Unbinder unBinder;
    protected AbstractGrandFatherActivity AGFActivity;


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(setLayoutId());

        unBinder = ButterKnife.bind(this);
        AGFActivity = this;



        onViewCreated();
        ActivityCollector.getInstance().addActivity(this);//压入Activity对象到Set集合中
        initEventAll();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        ActivityCollector.getInstance().removeActivity(this);
        unBinder.unbind();
    }

    /**
     * 功能：在对layout中的UI控件进行实例化之后
     * 所要执行的方法
     */
    protected void onViewCreated(){}
    protected abstract int setLayoutId();//设置Activity的UI布局

    protected abstract void initEventAll();//初始化数据
}
